# encoding: UTF-8
# 
# Copyright © 2011 Jesse Sielaff
# 

require 'minitest/autorun'
require 'number'

class TestComplex < MiniTest::Unit::TestCase
  def test_to_number_returns_number_with_same_value
    assert_equal(Number(1,2), (1+2.i).to_number)
  end
  
  def test_to_number_works_for_nan_real_part
    assert_equal(Number(Number.nan,2), (Float::NAN+2.i).to_number)
  end
  
  def test_to_number_works_for_nan_imag_part
    assert_equal(Number(1,Number.nan), (1+Float::NAN.i).to_number)
  end
  
  def test_to_number_works_for_pos_inf_real_part
    assert_equal(Number(Number.pos_inf,2), (Float::INFINITY+2.i).to_number)
  end
  
  def test_to_number_works_for_pos_inf_imag_part
    assert_equal(Number(1,Number.pos_inf), (1+Float::INFINITY.i).to_number)
  end
  
  def test_to_number_works_for_neg_inf_real_part
    assert_equal(Number(Number.neg_inf,2), (-Float::INFINITY+2.i).to_number)
  end
  
  def test_to_number_works_for_neg_inf_imag_part
    assert_equal(Number(1,Number.neg_inf), (1-Float::INFINITY.i).to_number)
  end
end
